package com.initialize.pub.dao;

import com.initialize.pub.generate.pojo.VSearch;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: jane
 * Date: 2020/3/7
 * Time: 3:30 下午
 * Description:
 */
@Repository
public interface VSearchDAO {
    @Select({
   "SELECT\n" +
           "\t* \n" +
           "FROM\n" +
           "\tv_search \n" +
           "WHERE\n" +
           "\t( title LIKE \"%\"#{key}\"%\" OR content LIKE \"%\"#{key}\"%\" OR classification LIKE \"%\"#{key}\"%\" OR label LIKE \"%\"#{key}\"%\" ) \n" +
           "\tAND STATUS = 1"
    })
    @Results({
            @Result(column = "aid", property = "aid", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "title", property = "title", jdbcType = JdbcType.VARCHAR),
            @Result(column = "label", property = "label", jdbcType = JdbcType.VARCHAR),
            @Result(column = "classification", property = "classification", jdbcType = JdbcType.VARCHAR),
            @Result(column = "release_time", property = "releaseTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "update_time", property = "updateTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "browse_the_number", property = "browseTheNumber", jdbcType = JdbcType.INTEGER),
            @Result(column = "thumb_up_number", property = "thumbUpNumber", jdbcType = JdbcType.INTEGER),
            @Result(column = "status", property = "status", jdbcType = JdbcType.INTEGER),
            @Result(column = "content", property = "content", jdbcType = JdbcType.LONGVARCHAR)
    })
    List<VSearch> selByKey(@Param("key") String key);
}